<?php
/**
 *
 * @Filename index.php $
 *
 * @Author nikm $
 *
 * @Date 2011-12-19 $
 */

error_reporting(E_ERROR);
//error_reporting(E_ALL|E_NOTICE);
ini_set('display_errors', 'on');

define('FROM_INDEX', true);
define('ROOT_PATH', substr(dirname(__FILE__), 0, -8) . '/');

require ROOT_PATH.'include/lib/load_setting.php';
load_setting('site_setting');
@header('Content-Type: text/html; charset='.CHARSET);

require ROOT_PATH.'config/config_servlet.php';
require ROOT_PATH.'include/function/global.func.php';
require ROOT_PATH.'servlet/include/function/servlet.func.php';

// Available modules
$mods = array('movie'=>1, 'movie_review'=>1);

$mod = isset($_GET['m']) ? $_GET['m'] : (isset($_POST['m']) ? $_POST['m'] : '');
$act = isset($_GET['a']) ? $_GET['a'] : (isset($_POST['a']) ? $_POST['a'] : '');
$request = isset($_GET['request']) ? $_GET['request'] : (isset($_POST['request']) ? $_POST['request'] : '');

if($request)
{
	$request = parse_json($request);
	
	// Request not in json format
	if(!$request || !is_array($request))
	{
		show_msg('002', STATUS_E);
	}
}

$mod_file = ROOT_PATH.'servlet/module/'.$mod.'.mod.php';
// Module does not exists
if(!file_exists($mod_file))
{
	show_msg('003', STATUS_E);
}

require_once $mod_file;

$request['mod'] = $mod;
$request['act'] = $act;

$module = new moduleObj($request);